package org.chat.hhdchat.component;

import lombok.Data;

@Data
public class R<T> {
    private int code;
    private String message;
    private T data;

    public R(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    // 成功响应（带数据）
    public static <T> R<T> success(T data) {
        return new R<>(200, "Success", data);
    }

    // 错误响应
    public static <T> R<T> error(int code, String message) {
        return new R<>(code, message, null);
    }
}
